package com.situ.day8;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class BorderLayoutDemo {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setTitle("Hello  BorderLayout");
		JPanel panel = new JPanel();
		frame.add(panel);
		//设置布局
		panel.setLayout(new BorderLayout());
		//创建组件
		JButton northButton = new JButton("北部");
		JButton southButton = new JButton("南部");
		JButton westButton = new JButton("西部");
		JButton eastButton = new JButton("东部");
		JButton centerButton = new JButton("中部");
		//添加组件
		panel.add(northButton, BorderLayout.NORTH);
		//panel.add(southButton, BorderLayout.SOUTH);
		panel.add(westButton, BorderLayout.WEST);
		//panel.add(eastButton, BorderLayout.EAST);
		panel.add(centerButton, BorderLayout.CENTER);
		//设置大小
		//width the new width of this component in pixels
		frame.setSize(500, 400);
		//设置初始位置
		frame.setLocation(500, 200);
		//关闭应用程序（设置frame默认关闭的操作，就是关闭时候退出整个应用）
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//默认是不显示
		frame.setVisible(true);
	}
}
